{% extends "dvaui/base.html" %}
{% load staticfiles %}

{% block page_content %}
    <section class="content-header" style="padding-top:0px" xmlns="http://www.w3.org/1999/html">
        <div class="row">
            <div class="box box-info">
                <div class="box-header">
                    <h2>Indexing, Detection & Analysis models
                        <a href="/stored_process#shortcuts" class="btn btn-success" style="float: right"><i
                                class="fa fa-plus-square"></i> Import/Train new models</a>
                    </h2>
                    {% if is_paginated %}
                        <div class="pagination text-center" style="width:100%">
                    <span class="page-links">
                        {% if page_obj.has_previous %}
                            <a class="btn btn-info" style="float:left"
                               href=".?page={{ page_obj.previous_page_number }}"><i class="fa fa-backward"></i>  Go back</a>
                        {% endif %}
                        <span class="page-current " style="font-size:24pt;font-weight:bold">
                            {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
                        </span>
                        {% if page_obj.has_next %}
                            <a class="btn btn-info" style="float:right" href=".?page={{ page_obj.next_page_number }}">Load more  <i
                                    class="fa fa-forward"></i></a>
                        {% endif %}
                    </span>
                        </div>
                    {% endif %}
                </div>

            </div>
        </div>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-lg-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3>Models</h3>
                    </div>
                    <div class="box-body">
                        <table class="table dataTables-dict">
                            <thead>
                            <tr>
                                <th>Name</th>
                                <th class="text-center">Type</th>
                                <th class="text-center">Sub type</th>
                                <th>Mode</th>
                                <th class="text-center">Shasum</th>
                                <th class="text-center">Training Set</th>
                                <th class="text-center">Training event</th>
                                <th class="text-center">Details</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for i in object_list %}
                                <tr>
                                    <td>{{ i.name }} </td>
                                    <td>{{ i.get_model_type_display }} </td>
                                    <td>{{ i.get_detector_type_display }} </td>
                                    <td>{{ i.get_mode_display }} </td>
                                    <td>{{ i.shasum }}</td>
                                    <td class="text-center">{% if i.training_set %}
                                        <a href="/training_sets/{{ i.training_set.pk }}">Training set</a>{% endif %}
                                    </td>
                                    <td class="text-center">{% if i.event %}
                                        <a href="/task_detail/{{ i.event_id }}">Training event</a>{% endif %}</td>
                                    <td class="text-center"><a href="/models/{{ i.pk }}">details</a></td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="col-lg-12">

                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3>Exports</h3>
                    </div>
                    <div class="box-body">
                        <table class="table dataTables-dict">
                            <thead>
                            <tr>
                                <th class="text-center">Event</th>
                                <th class="text-center">Model</th>
                                <th class="text-center">Completed</th>
                                <th class="text-center">URL</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for e in exports %}
                                <tr>
                                    <td><a href="/task_detail/{{ e.event_id }}">{{ e.event_id }}</a></td>
                                    <td>{{ e.event.arguments.trainedmodel_selector }}</td>
                                    <td class="text-center">{{ e.created }}</td>
                                    <td class="text-center"><a href="{{ e.url }}" target="_blank" rel="noreferrer"
                                                               rel="noopener">{{ e.url }}</a></td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>


        </div>
    </section>
{% endblock %}
{% block page_js %}
    <script>
        $(document).ready(function () {
            InitializeTables();
        })
    </script>
{% endblock %}
